﻿$G.string = {
	formatpattern: [ /\{#0\}/gm, /\{#1\}/gm, /\{#2\}/gm, /\{#3\}/gm, /\{#4\}/gm ],
	format: function () {
		if (arguments.length > $G.string.formatpattern.length + 1) {
			for (var a = $G.string.formatpattern.length; a < arguments.length - 1; a++)
				$G.string.formatpattern.push(new RegExp("\\{#" + a + "\\}", "gm"));
		}
		var newStr = arguments[0];
		for (var i = 1; i < arguments.length; i++) {
			newStr = newStr.replace($G.string.formatpattern[i-1], arguments[i]);
		}
		return newStr;
	}
}

String.prototype.replaceAll = function (search, replace) {
	if (replace === undefined) return this.toString();

	return this.split(search).join(replace);
}
